﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp10
{
   public class DbHelper
    {
        public static string ConStr = "server=127.0.0.1;database=Blogs;uid=sa;pwd=lmm974412";

        public static DataTable GetDataTable(string sql)
        {
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, ConStr);

            DataTable dt = new DataTable();

            dataAdapter.Fill(dt);

            return dt;
        }

        public static int AddOrUpdateOrDelete(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(ConStr);

            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);

            sqlConnection.Open();

            return sqlCommand.ExecuteNonQuery();



        }

            

    }
}
